<!DOCTYPE HTML>
<html>
<head>
	<meta charset="utf-8">
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
	<link rel="Bookmark" href="imgs/favicon.ico"/>
	<link rel="Shortcut Icon" href="imgs/favicon.ico"/>
	<link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css"/>
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css"/>
	<link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css"/>
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin"/>
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css"/>
	<title>商城</title>
	<style type="text/css">
		.title { margin-left: 10px; padding: 0; padding-left: 10px; border-left: 5px solid #0088CC; font-weight: bolder; }
	</style>
</head>
<body>
<!--顶部-->
<header class="navbar-wrapper"></header>
<!--左侧菜单-->
<aside class="Hui-aside">
	<div class="menu_dropdown bk_2" id="leftMenu"></div>
</aside>

<section class="Hui-article-box">
	<nav class="breadcrumb">
		<i class="Hui-iconfont">&#xe67f;</i>
		<a href="index.html" class="maincolor">首页</a>
		<span class="c-gray en">&gt;</span> 用户管理
		<span class="c-gray en">&gt;</span> 微信配置
	</nav>
	<article class="cl pd-20">
		<form class="form form-horizontal" id="form-member-add">
			<div class="row cl title">
				微信支付配置信息
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">
					<span class="c-red">*</span> 应用appid：
				</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="text" class="input-text" id="appid"/>
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">
					<span class="c-red">*</span> 商户号mchid：
				</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="text" class="input-text" id="mchid"/>
				</div>
			</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3">
						<span class="c-red">*</span> 支付通知接口：
					</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="text" class="input-text" id="notify_url"/>
					</div>
				</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">
					<span class="c-red">*</span> 证书地址：
				</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="text" class="input-text" id="apiclient_key"/>
				</div>
			</div>
			<div class="row cl">
				<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
					<input class="btn btn-primary radius" type="button" value="&nbsp;&nbsp;提 交&nbsp;&nbsp;" onclick="modify();"/>
				</div>
			</div>
		</form>
	</article>
</section>

<!--自定义弹窗-->
<span id="msgPop"></span>
</body>
</html>


<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="static/h-ui/js/H-ui.js"></script>
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.page.js"></script>
<script type="text/javascript" src="js/config.js"></script>
<script type="text/javascript" src="js/view.js"></script>
<script type="text/javascript">
	(function () {
		getOne();
	})();
	//获取配置
	function getOne(){
		$.ajax({
			type: apis.wxConfigOne.method,
			url: apis.wxConfigOne.url,
			data: {},
			success: function (res) {
				console.log(res);
				if (res.code < 0) {
					msgPop({msg: res.msg}); return
				}
				$('#appid')[0].value = res.data.xcx_pay_appid;
				$('#mchid')[0].value = res.data.xcx_pay_mchid;
				$('#notify_url')[0].value = res.data.notify_url;
				$('#apiclient_key')[0].value = res.data.apiclient_key;
			},
			error: function () {
				console.log('错误啦');
			}
		});
	}
	//设置配置
	function modify(){
		var formData = {
			appid: $('#appid').val(),
			mchid: $('#mchid').val(),
			notify_url: $('#notify_url').val(),
			apiclient_key: $('#apiclient_key').val(),
		};
		if (!formData.appid) {
			msgPop({msg: 'appid必须的'}); return
		}
		if (!formData.mchid) {
			msgPop({msg: 'mchid必须的'}); return
		}
		$.ajax({
			type: apis.wxConfigModify.method,
			url: apis.wxConfigModify.url,
			data: formData,
			success: function (res) {
				console.log(res);
				if (res.code < 0) {
					msgPop({msg: res.msg}); return
				}
				msgPop({msg: '修改成功'});
				setTimeout(function () {
					window.location.href = '';
				}, 1000);
			},
			error: function () {
				console.log('错误啦');
			}
		});
	}
</script>